package com.example.teacher.controller;


import com.example.commonutils.ResultData;
import com.example.teacher.entity.subject.OneSubject;
import com.example.teacher.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-05-24
 */
@RestController
@RequestMapping("/backstage/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;

    //添加课程分类 将文件上传到方法中
    @PostMapping(value = "addSubject",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultData addSubject(MultipartFile file){
        subjectService.saveSubject(file,subjectService);
        return ResultData.ok();
    }
    @GetMapping(value = "getAllSubject",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultData getAllSubject(){
        List<OneSubject> list=subjectService.getAllOneSubject();
        return ResultData.ok().data("list",list);
    }
}

